

function onReceiveDownloadJob(pipe) {
    pipe.onMessage.addListener(function(msg) {
        chrome.downloads.download({url:msg['music_url'], filename:msg['name']}, function(id){
        });
    });
}
chrome.runtime.onConnect.addListener(onReceiveDownloadJob);

/*function showPageAction(tabId, changeInfo, tab) {
    if(getDomainFromUrl(tab.url).toLowerCase()=="music.163.com"){
        chrome.action.show(tabId);
    }
};
chrome.tabs.onUpdated.addListener(showPageAction);*/

function onInstalled(details) {
    if(details['reason'] == 'install') {
        chrome.tabs.create({url: "options.html"});
    }
    if(details['reason'] == 'update' && details['previousVersion'].indexOf('1.4') > -1) {
        chrome.tabs.create({url: "options.html"});
    }
}
chrome.runtime.onInstalled.addListener(onInstalled);
